/* eslint-disable vue/require-default-prop */
<template>
  <div id="linebox" class="line-box" style="height:300px;" />
</template>

<script>
export default {
  props: {
    // eslint-disable-next-line vue/require-default-prop
    lineData: {
      type: Object
    }
  },
  data() {
    return {
      // 基于准备好的dom，初始化echarts实例
      myChart: null
    }
  },
  watch: {
    lineData: function() {
      this.myChart.setOption(this.lineData)
    }
  },
  created() {

  },
  mounted() {
    this.myChart = this.$echarts.init(document.getElementById('linebox'))
    console.log('--------------this.options:', this.lineData)
    // 使用刚指定的配置项和数据显示图表。
    this.myChart.setOption(this.lineData || {
      title: {
        text: 'ECharts 入门示例'
      },
      tooltip: {},
      legend: {
        data: ['死数据']
      },
      xAxis: {
        data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
      },
      yAxis: {},
      series: [
        {
          name: '销量',
          type: 'line',
          smooth: true,
          data: [5, 20, 36, 10, 10, 20]
        }
      ]
    })
  }
}
</script>

<style>
  .line-box {
    background: #fff;
    padding: 10px;
    margin-top: 30px;
  }
</style>
